#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

void swap(char * s, uint32_t idx1, uint32_t idx2)
{
	char ch = s[idx1];
	s[idx1] = s[idx2];
	s[idx2] = ch;
}

void permutate(char * s, uint32_t idx)
{
	// exit condition
	if(idx == (strlen(s) - 1))
	{
		printf("%s\n", s);
		return;
	}

	uint32_t j = 0;
	for(j = idx; j < strlen(s); j++)
	{
		swap(s, idx, j);
		permutate(s, idx + 1);
		swap(s, idx, j);
	}
}

int main(int argc, char *argv[]) {
	printf("Permutate practice\n");

	char s[] = "12345";

	permutate(s, 0);

	return EXIT_SUCCESS;
}
